layui.define(["table", "form"], function(e) {
    var admin = layui.admin;
    var $ = layui.$,
        form = layui.form,
        table = layui.table;
    //监听搜索
    form.on('submit(LAY-info-front-search)', function(data) {
        var field = data.field;
        //执行重载
        table.reload('LAY-info-manage', {
            where: field,
            page: {
                curr: 1
            },
        });
    });
    //事件
    var active = {
        batchpush: function() {
            var checkStatus = table.checkStatus('LAY-info-manage'),
                checkData = checkStatus.data; //得到选中的数据
            if (checkData.length === 0) {
                return layer.msg('请选择数据');
            }
            layer.confirm('确定推送吗？', function() {
                //执行 Ajax 后重载
                var _ids = layui.getParamValues(checkData, 'mission_id');
                layui.$.get(layui.setter.app_url + 'missionlinks/batchPush', {
                    id: _ids.join()
                }, function(data) {
                    layer.msg(data.msg);
                    table.reload('LAY-info-manage');
                });
            });
        },
    };
    $('.layui-btn.layuiadmin-btn-info').on('click', function() {
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
    //表格内处理     
    table.render({
        elem: "#LAY-info-manage",
        url: app_url + "missionlinks/listData",
        cols: [
            [{
                checkbox: true
            }, {
                field: "id",
                title: "ID",
                sort: !0,
                width: 80,
            }, {
                field: "href",
                title: "链接",
                templet: '<div>{{d.links_data.links}}</div>',
            }, {
                field: "mission_id",
                title: "任务ID",
            }, {
                field: "title",
                title: "任务标题",
            }, {
                field: "create_time",
                title: "创建时间",
            }, {
                field: "update_time",
                title: "更新时间",
            }, {
                field: "mission_status_txt",
                title: "任务状态",
            }, {
                field: "status_txt",
                title: "推送状态",
            }]
        ],
        page: !0,
        limit: 10,
        height: "full-120",
        text: "对不起，加载出现异常！"
    }), table.on("tool(LAY-info-manage)", function(e) {}), e("missionlinks", {})
});